package com.nch.haitonghop.others;

import android.content.res.Resources;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * Created by nguyenconghuy on 1/1/15.
 */
public class Utils {
    public static String readStringFromRaw(Resources resources, int resourceId) {
        InputStream inputStream = resources.openRawResource(resourceId);
        String resultString = null;

        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder stringBuilder = new StringBuilder();
        try {
            String line = reader.readLine();
            while (line != null) {
                stringBuilder.append(line);
                line = reader.readLine();
            }
            resultString = stringBuilder.toString();
        }
        catch (IOException ex) {
//            Log.d("", "Exception: " + ex);
        }

        return resultString;
    }
}
